package framework
{
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;

	public class HandleResponder implements IResponder
	{
		public var resultHandler:Function;
		public var faultHandler:Function;
		
		public function HandleResponder()
		{
		}

		public function result(data:Object):void
		{
			var e:ResultEvent = ResultEvent(data);
			try
			{
				resultHandler(e);
			}
			catch(er:ArgumentError)
			{
				if (er.errorID == 1063)
				{
					resultHandler();
				}
			}
			
		}
		
		public function fault(info:Object):void
		{
			trace("handle fault: "+ info);
			var e:FaultEvent = FaultEvent(info);
			if (faultHandler != null)
			{
				faultHandler(e);
			}
		}
		
	}
}